package com.x;

import com.x.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * ClassName: App2
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.08.31 16:27
 */
public class App2 {
    public static void main(String[] args) {
        //获取Ioc容器
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        
        //获取Bean
            //几种方式: getBean中可为Bean id 或者 实现类 或者 父接口
            //BookService bookService = (BookService) context.getBean(BookService.class);
            //BookService bookService = (BookServiceImpl) context.getBean("bookService");
        BookService bookService = context.getBean("bookService", BookService.class);
        bookService.save();
    }
}
